﻿@using Board.Models

@{
    ViewBag.Title = "UserModify";
}

<h2>Edit User Info</h2>
<div id="jqueryFormDiv">
    @using (Html.BeginForm("UserSave", "Account", FormMethod.Post, new { @id = "UserForm", @class = "jquery-form" }))
    {
        @Html.ValidationSummary(true)

        if (ViewBag.User != null)
        {
            WebUser user = (WebUser) ViewBag.User;
            WebUser creator = new WebUser(user.CreatedBy);
            <text>
                <div id="UserInfoDiv">
                    <fieldset>
                        <legend>t_UserProfile</legend>

                        <div class="display-label">
                            User ID
                        </div>
                        <div class="display-field">
                            @(user.UserId)  @Html.Hidden("UserId", @user.UserId)
                        </div>

                        <div class="display-label">
                            Username
                        </div>
                        <div class="display-field">
                            @Html.TextBox("Username", user.Username)
                        </div>

                        <div class="display-label">
                            First Name
                        </div>
                        <div class="display-field">
                            @Html.TextBox("FirstName", user.FirstName)
                        </div>

                        <div class="display-label">
                            Last Name
                        </div>
                        <div class="display-field">
                            @Html.TextBox("LastName", user.LastName)
                        </div>

                        <div class="display-label">
                            User Type
                        </div>
                        <div class="display-field">
                            @if (ViewBag.UserTypeDropdown == null)
                            {
                                @Html.TextBox("UserType", user.UserType)
                            }
                            else
                            {
                                @Html.DropDownList("UserType", (IEnumerable<SelectListItem>) ViewBag.UserTypeDropdown)
                            }
                    
                        </div>

                        <div class="display-label">
                            Creation Date
                        </div>
                        <div class="display-field">
                            @(user.CreationDate)
                        </div>

                        <div class="display-label">
                            Show All Beds<br />in one screen
                        </div>
                        <div class="display-field">
                            @Html.CheckBox("ShowAllBed", user.ShowAllBed)
                        </div>

                        <div class="display-label">
                            Created By
                        </div>
                        <div class="display-field">
                            @(creator.UserId > 0 ? creator.FullName : "")
                        </div>

                        <div class="display-label">
                            Default Site
                        </div>
                        <div class="display-field">
                            @if (ViewBag.DefaultSiteDropdown == null)
                            {
                                <text>
                                    @(user.DefaultSite != null ? user.DefaultSite.SiteId : "")
                                </text>
                            }
                            else
                            {
                                <text>
                                    @Html.DropDownList("Site", (IEnumerable<SelectListItem>) ViewBag.DefaultSiteDropdown)
                                </text>
                            }
                        </div>

                        <div class="display-label">
                            Default Unit
                        </div>
                        <div class="display-field" id="UnitDiv">
                            @if (ViewBag.DefaultUnitDropdown == null)
                            {
                                <text>
                                    @(user.DefaultUnit != null ? user.DefaultUnit.UnitId : "")
                                </text>
                            }
                            else
                            {
                                <text>
                                    @Html.DropDownList("Unit", (IEnumerable<SelectListItem>) ViewBag.DefaultUnitDropdown)
                                </text>
                            }
                        </div>
                        
                        <div class="display-label">
                            Display records per page
                        </div>
                        <div class="display-field">
                            @Html.TextBox("DefaultRecordsPerPage",user.DefaultRecordsPerPage)
                        </div>
                        

                        <div class="display-label">
                            User Role
                        </div>
                        <div class="display-field">
                            @Html.DropDownList("Roles", (IEnumerable<SelectListItem>) ViewBag.RoleDropdown, new {multiple = "multiple", @class="multiple-select"})
                        </div>
                    </fieldset>
                </div>
                <p>
                    <input type="submit" value="Save" />
                </p>
                <p>
                    @Html.ActionLink("Edit", "UserModify", new {UserId = user.UserId}) |
                    @Html.ActionLink("Back to List", "UserList")
                </p>
            </text>
        }
    }
</div>


@section Scripts {
    <script src="~/Scripts/account.js"></script>
    <script src="~/Scripts/bootstrap.min.js"></script>
    <script> $("#UserType").dropdown();</script>

}

@section styles
{
    <link href="~/Content/bootstrap-responsive.min.css" rel="stylesheet" />
    <link href="~/Content/bootstrap.min.css" rel="stylesheet" />

}
